10261 - Ferry loading (DP, programación dinámica) && 410 - Station balance (Dijkstra...
[and.git] / 11335 - Discrete pursuit / 11335.cpp
blob21be3f6578ed9bd4bda59df2b02a51dbde261515
1 #include <iostream>
3 using namespace std;
5 int main(){
6 unsigned int a,u,v;
7 while (cin >> a >> u >> v){
8 if (a == 0){
9 cout << "0" << endl;
10 }else{
11 unsigned int min, px, lx, py, ly, t;
12 px = 0;
13 lx = a;
14 t = 0;
15 while (px < lx){
16 px = (t*(t+1))/2;
17 lx = a + u*t;
18 ++t;
20 --t;
21 min = t;
23 py = ly = 0;
24 t = 1;
25 while (py < ly){
26 py = (t*(t+1))/2;
27 ly = v*t;
28 ++t;
30 --t;
32 if (t > min) min = t;
33 cout << min << endl;
36 return 0;